home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / OWLINC.PAK / SCROLLBA.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  4KB  |  154 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   10.6  $
  6. //
  7. // Definition of class TScrollBar.  This defines the basic behavior of all
  8. // scrollbar controls.
  9. //----------------------------------------------------------------------------
  10. #if !defined(OWL_SCROLLBAR_H)
  11. #define OWL_SCROLLBAR_H
  12.  
  13. #if !defined(OWL_CONTROL_H)
  14. # include <owl/control.h>
  15. #endif
  16.  
  17. #if defined(BI_NAMESPACE)
  18. namespace OWL {
  19. #endif
  20.  
  21. // Generic definitions/compiler options (eg. alignment) preceeding the
  22. // definition of classes
  23. #include <services/preclass.h>
  24.  
  25. //
  26. // class TScrollBar
  27. // ~~~~~ ~~~~~~~~~~
  28. class _OWLCLASS TScrollBar : public TControl {
  29.   public:
  30.     TScrollBar(TWindow*        parent,
  31.                int             id,
  32.                int x, int y, int w, int h,
  33.                bool            isHScrollBar,
  34.                TModule*        module = 0);
  35.  
  36.     TScrollBar(TWindow* parent, int resourceId, TModule* module = 0);
  37.  
  38.     int    GetLineMagnitude() const;
  39.     void   SetLineMagnitude(int linemagnitude);
  40.  
  41.     int    GetPageMagnitude() const;
  42.     void   SetPageMagnitude(int pagemagnitude);
  43.  
  44.     // Virtual functions to interface to scrollbars & derived
  45.     //
  46.     virtual void  GetRange(int& min, int& max) const;
  47.     virtual int   GetPosition() const;
  48.     virtual void  SetRange(int min, int max, bool redraw = true);
  49.     virtual void  SetPosition(int thumbPos, bool redraw = true);
  50.     virtual int   DeltaPos(int delta);
  51. #if defined(BI_PLAT_WIN32)
  52.     virtual void  GetScrollInfo(SCROLLINFO* info) const;
  53.     virtual void  SetScrollInfo(SCROLLINFO* info, bool redraw = true);
  54. #endif
  55.  
  56.     // Override TWindow virtual member functions
  57.     //
  58.     uint          Transfer(void* buffer, TTransferDirection direction);
  59.  
  60.     // Called by EvHScroll and EvVScroll response table handlers
  61.     //
  62.     // These routines all end up calling SetPosition()
  63.     //
  64.     virtual void  SBLineUp();
  65.     virtual void  SBLineDown();
  66.     virtual void  SBPageUp();
  67.     virtual void  SBPageDown();
  68.     virtual void  SBThumbPosition(int thumbPos);
  69.     virtual void  SBThumbTrack(int thumbPos);
  70.     virtual void  SBTop();
  71.     virtual void  SBBottom();
  72.     virtual void  SBEndScroll();
  73.  
  74.     // Response table handlers that call above virtual functions in
  75.     // response to messages sent by to us by TWindow::DispatchScroll()
  76.     //
  77.     void          EvHScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
  78.     void          EvVScroll(uint scrollCode, uint thumbPos, HWND hWndCtl);
  79.  
  80.   protected:
  81.     // Override TWindow virtual member functions
  82.     //
  83.     char far*     GetClassName();
  84.     void          SetupWindow();
  85.  
  86.   public_data:
  87.     int  LineMagnitude;
  88.     int  PageMagnitude;
  89.  
  90.   private:
  91.     // Hidden to prevent accidental copying or assignment
  92.     //
  93.     TScrollBar(const TScrollBar&);
  94.     TScrollBar& operator=(const TScrollBar&);
  95.  
  96.   DECLARE_RESPONSE_TABLE(TScrollBar);
  97.   DECLARE_STREAMABLE(_OWLCLASS, TScrollBar, 1);
  98. };
  99.  
  100. //
  101. // scroll bar notification macros. methods are: void method()
  102. //
  103. // EV_SB_LINEDOWN(id, method)
  104. // EV_SB_LINEUP(id, method)
  105. // EV_SB_PAGEDOWN(id, method)
  106. // EV_SB_PAGEUP(id, method)
  107. // EV_SB_TOP(id, method)
  108. // EV_SB_BOTTOM(id, method)
  109. // EV_SB_THUMBPOSITION(id, method)
  110. // EV_SB_ENDSCROLL(id, method)
  111. // EV_SB_BEGINTRACK(id, method)
  112.  
  113. //
  114. // struct TScrollBarData
  115. // ~~~~~~ ~~~~~~~~~~~~~~
  116. //  TScrollBar transfer structure
  117. //
  118. struct TScrollBarData {
  119.   int  LowValue;
  120.   int  HighValue;
  121.   int  Position;
  122. };
  123.  
  124. // Generic definitions/compiler options (eg. alignment) following the
  125. // definition of classes
  126. #include <services/posclass.h>
  127.  
  128. #if defined(BI_NAMESPACE)
  129. } // namespace OWL
  130. #endif
  131.  
  132. //----------------------------------------------------------------------------
  133. // Inline implementation
  134. //
  135.  
  136. //
  137. // Return the current delta to move the thumb when line up/line down is
  138. // received.
  139. //
  140. inline int TScrollBar::GetLineMagnitude() const
  141. {
  142.   return LineMagnitude;
  143. }
  144.  
  145. //
  146. // Set the delta to move the thumb when line up/line down is received.
  147. //
  148. inline void TScrollBar::SetLineMagnitude(int linemagnitude)
  149. {
  150.   LineMagnitude = linemagnitude;
  151. }
  152.  
  153. #endif  // OWL_SCROLLBAR_H
  154.